package com.example.testanimation.objectanimation;

import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.PropertyValuesHolder;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import com.scenic.rd_android.R;

/**
 * Created by scenic on 3/26/15.
 */
public class SimpleAnimation extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.layout_value_animation_simpleanimation);

    }

    public void animation(View view){
        ImageView animationView = (ImageView) findViewById(R.id.id_imageView_1);

        {
//            PropertyValuesHolder holder1 = PropertyValuesHolder.ofFloat("rotation", 0f, 360f);
//            PropertyValuesHolder holder2 = PropertyValuesHolder.ofFloat("translationX", 0f, 360f);
//            PropertyValuesHolder holder3 = PropertyValuesHolder.ofFloat("translationY",0f,360f);
//            ObjectAnimator.ofPropertyValuesHolder(animationView,holder1,holder2,holder3).setDuration(1000).start();
        }

        {

            ObjectAnimator animator1 = ObjectAnimator.ofFloat(animationView,"rotation", 0f, 360f);
            ObjectAnimator animator2 = ObjectAnimator.ofFloat(animationView,"translationX", 0f, 360f);
            ObjectAnimator animator3 = ObjectAnimator.ofFloat(animationView,"translationY",0f,360f);
            ObjectAnimator animator4 = ObjectAnimator.ofFloat(animationView,"scaleX",1f,2f);

            AnimatorSet set = new AnimatorSet();
//            set.playTogether(animator1,animator2,animator3);

//            set.playSequentially(animator1,animator2,animator3);

//            set.play(animator2).with(animator3);
//            set.play(animator1).after(animator2);

            set.play(animator4);
            set.setDuration(1000);
            set.start();
        }

    }
}